package com.efesco.service.product;

import com.bstek.dorado.common.*;
import com.bstek.dorado.data.*;
import com.bstek.dorado.view.*;
import com.bstek.dorado.view.data.*;
import com.bstek.dorado.view.control.*;
import com.efesco.common.DBTools;

/**
 * productEditViewModel
 */
public class productEditViewModel extends DefaultViewModel {
  public void init(int state)
      throws Exception {
    // Add your code here
    super.init(state);
  }

  protected void initDatasets()throws Exception {
    super.initDatasets();
    // Add your code here
  }

  protected void initControls() throws Exception {
    super.initControls();
    // Add your code here
  }

  protected void doLoadData() throws Exception {
    // Add your code here
    super.doLoadData();
  }

  public void addProduct(ParameterSet parameters) throws Exception {
	  System.out.println("******************************************************");
	  String productId=DBTools.getNewId("general");
	  Dataset datasetProduct=this.getDataset("datasetProduct");
	  datasetProduct.setValue("product_id",productId);
	  
	  Dataset datasetProductRoleRight=this.getDataset("datasetProductRoleRight");
	  datasetProductRoleRight.moveFirst();
	  while(!datasetProductRoleRight.isLast()){
		  datasetProductRoleRight.setValue("product_id",productId);
		  datasetProductRoleRight.moveNext();
	  }
	  
	  super.doUpdateData(parameters);
	  Dataset datasetRelation=getDataset("datasetProductRelation");
		//datasetProduct.
		//dataset.setValue("is_enabled","0");
  }

}
